package com.dotto.atos.fragments;

import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

import com.dotto.atos.R;
import com.dotto.atos.activity.HomeActivity;
import com.dotto.atos.utils.MessageUtil;

public class CardApplicationMenuFragment extends Fragment {

	public static final String TAG = "CardApplicationMenuFragment";
	private View fragmentView;
	private Activity mActivity;
	@SuppressWarnings("unused")
	private CardApplicationMenuFragment instance;

	@SuppressWarnings("unused")
	private MessageUtil messageUtil;

	private Button goldCard;
	private Button classicCard;
	private Button silverCard;
	private Button silverVisaCard;
	private Button platinumCard;
	private Button menuItemExit;

	public int selectedCard;

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		selectedCard = -1;
		if (fragmentView == null) {
			fragmentView = inflater.inflate(R.layout.fragment_card_menu,
					container, false);
		} else {
			((ViewGroup) fragmentView.getParent()).removeView(fragmentView);
		}
		mActivity = this.getActivity();
		instance = this;
		messageUtil = new MessageUtil(mActivity);
		initView();
		return fragmentView;
	}

	public void initView() {
		if (fragmentView != null) {
			goldCard = (Button) fragmentView
					.findViewById(R.id.menu_item_gold_card);
			goldCard.setOnClickListener(onClickGoldCard);

			classicCard = (Button) fragmentView
					.findViewById(R.id.menu_item_classic_card);
			classicCard.setOnClickListener(onClickClassicCard);

			silverCard = (Button) fragmentView
					.findViewById(R.id.menu_item_silver_card);
			silverCard.setOnClickListener(onClickSilverCard);

			silverVisaCard = (Button) fragmentView
					.findViewById(R.id.menu_item_silver_visa_card);
			silverVisaCard.setOnClickListener(onClickVisaCard);

			platinumCard = (Button) fragmentView
					.findViewById(R.id.menu_item_platinium_card);
			platinumCard.setOnClickListener(onClickPlatinumCard);

			menuItemExit = (Button) fragmentView
					.findViewById(R.id.menu_item_exit);
			menuItemExit.setOnClickListener(onClickExit);

		}
	}

	private OnClickListener onClickGoldCard = new OnClickListener() {
		@Override
		public void onClick(View v) {
			selectedCard = 1;
			HomeActivity.instance.showCardApplication1Fragment(1);
		}
	};

	private OnClickListener onClickClassicCard = new OnClickListener() {
		@Override
		public void onClick(View v) {
			selectedCard = 2;
			HomeActivity.instance.showCardApplication1Fragment(1);
		}
	};

	private OnClickListener onClickSilverCard = new OnClickListener() {
		@Override
		public void onClick(View v) {
			selectedCard = 3;
			HomeActivity.instance.showCardApplication1Fragment(1);
		}
	};

	private OnClickListener onClickVisaCard = new OnClickListener() {
		@Override
		public void onClick(View v) {
			selectedCard = 4;
			HomeActivity.instance.showCardApplication1Fragment(1);
		}
	};

	private OnClickListener onClickPlatinumCard = new OnClickListener() {
		@Override
		public void onClick(View v) {
			selectedCard = 5;
			HomeActivity.instance.showCardApplication1Fragment(1);
		}
	};

	private OnClickListener onClickExit = new OnClickListener() {
		@Override
		public void onClick(View v) {
			selectedCard = -1;
			HomeActivity.instance.showMenuFragment(-1);
		}
	};
}
